<?php
require_once(Kohana::find_file('vendor','phprpc/phprpc_client'));
/**
 * Date: 15-3-24
 * Time: 上午10:11
 */
class stagerpc
{
    //获取phprpc客户端
    public static function getClient($server,$uri='')
    {
        $server = kohana::$config->load('stage')->get($server);

        $client = new PHPRPC_Client();
        $client->useService($server.$uri);

        return $client;
    }

    //phprpc获取速卖通销量
    public static function getSmtSysSkuSales($sql, &$data)
    {
        $client=self::getClient('smtSys','putSmtSysSkuSales');
        $data = json_decode($client->getinfo($sql),true);
        return !empty($data);
    }

    //phprpc获取亚马逊销量
    public static function getAmazonSkuSales($sql, &$data)
    {
        $client=self::getClient('amazon','putAmazonSkuSales');
        $data = json_decode($client->getinfo($sql),true);
        return !empty($data);
    }

    //phprpc获取wish销量
    public static function getWishSkuSales($sql, &$data)
    {
        $client=self::getClient('wish','adapter');
        $data = json_decode($client->putWishSkuSales($sql),true);
        return !empty($data);
    }

    public static function addColumn ($sql) {
        $client=self::getClient('smtSys','putSmtSysSkuSales');
        $client->getinfo($sql);
    }
}